package com.zhangx.study.demo.process;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;

/**
 * @ClassName MainProcess
 * @Description TODO
 * @Author zhangx
 * @Date 2021/5/25 8:26
 **/
public class MainProcess {

    public static void main(String[] args) {
//        java虚拟机的线程管理接口
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
//        获取线程信息
        ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(false, false);
        for (ThreadInfo info:threadInfos) {
            System.out.println(info.getThreadId()+":"+info.getThreadName());
        }
    }
}
